#include <stdio.h>

void sort(int n,int nums[n]){
    n = n + 1;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t z = i+1; z < n; z++)
        {
            if(nums[i]<nums[z]){
                int temp = nums[i];
                nums[i] = nums[z];
                nums[z] = temp;
            }
        }
    }
    printf("%d\n", nums[0]);
}

int main(int argc, char *argv[]) {

    int nums[100]={0};
    int n = 0, index = -1;
    while (scanf("%d",&n)!=EOF)
    {
        if(n==0){
            sort(index, nums);
            index = -1;
            continue;
        }

        nums[++index] = n;
    }
    

    return 0;
}